package com.edgclub.edg.adapter.adapteruitls;

import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 */
public  class RViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,View.OnLongClickListener {
    public MyItemClickListener mListener;
    public MyItemLongClickListener mLongClickListener;

    public RViewHolder(View view,MyItemClickListener listener,MyItemLongClickListener longClickListener){
        super(view);
        this.mListener = listener;
        this.mLongClickListener = longClickListener;
        view.setOnClickListener(this);
        view.setOnLongClickListener(this);
    }


    /**
     * 点击监听
     */
    @Override
    public void onClick(View v) {
        if(mListener != null){
            mListener.onItemClick(v,getPosition()-1);
        }
    }

    /**
     * 长按监听
     */
    @Override
    public boolean onLongClick(View arg0) {
        if(mLongClickListener != null){
            mLongClickListener.onItemLongClick(arg0, getPosition()-1);
        }
        return true;
    }
}
